package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SystemRealTime;
import com.ruoyi.system.service.ISystemRealTimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统实时状态Controller
 * 
 * @author ruoyi
 * @date 2023-11-13
 */
@RestController
@RequestMapping("/system/time")
public class SystemRealTimeController extends BaseController
{
    @Autowired
    private ISystemRealTimeService systemRealTimeService;

    /**
     * 查询系统实时状态列表
     */
    @PreAuthorize("@ss.hasPermi('system:time:list')")
    @GetMapping("/list")
    public TableDataInfo list(SystemRealTime systemRealTime)
    {
        startPage();
        List<SystemRealTime> list = systemRealTimeService.selectSystemRealTimeList(systemRealTime);
        return getDataTable(list);
    }

    /**
     * 导出系统实时状态列表
     */
    @PreAuthorize("@ss.hasPermi('system:time:export')")
    @Log(title = "系统实时状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SystemRealTime systemRealTime)
    {
        List<SystemRealTime> list = systemRealTimeService.selectSystemRealTimeList(systemRealTime);
        ExcelUtil<SystemRealTime> util = new ExcelUtil<SystemRealTime>(SystemRealTime.class);
        util.exportExcel(response, list, "系统实时状态数据");
    }

    /**
     * 获取系统实时状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:time:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(systemRealTimeService.selectSystemRealTimeById(id));
    }

    /**
     * 新增系统实时状态
     */
    @PreAuthorize("@ss.hasPermi('system:time:add')")
    @Log(title = "系统实时状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SystemRealTime systemRealTime)
    {
        return toAjax(systemRealTimeService.insertSystemRealTime(systemRealTime));
    }

    /**
     * 修改系统实时状态
     */
    @PreAuthorize("@ss.hasPermi('system:time:edit')")
    @Log(title = "系统实时状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SystemRealTime systemRealTime)
    {
        return toAjax(systemRealTimeService.updateSystemRealTime(systemRealTime));
    }

    /**
     * 删除系统实时状态
     */
    @PreAuthorize("@ss.hasPermi('system:time:remove')")
    @Log(title = "系统实时状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(systemRealTimeService.deleteSystemRealTimeByIds(ids));
    }
}
